<template>
  <el-dialog title="资源编辑" width="500px" v-model="dialogFormVisible">
    <el-form :model="form" size="small">
      <el-form-item label="名称" :label-width="formLabelWidth">
        <el-input v-model="form.resources_name" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="类型" :label-width="formLabelWidth">
        <el-select v-model="form.file_type" placeholder="请选类型">
          <el-option label="图片" :value="1"></el-option>
          <el-option label="视频" :value="2"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="资源上传" :label-width="formLabelWidth">
        <Upload></Upload>
      </el-form-item>
      <el-form-item label="描述" :label-width="formLabelWidth">
        <el-input
          type="textarea"
          v-model="form.business_describe"
          autocomplete="off"
        ></el-input>
      </el-form-item>
    </el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button size="small" @click="cancelFunc()">取 消</el-button>
        <el-button size="small" type="primary" @click="confirmFunc()"
          >确 定</el-button
        >
      </span>
    </template>
  </el-dialog>
</template>

<script>
import Upload from "@/components/upload/Upload.vue";
export default {
  components:{
    Upload
  },
  data() {
    return {
      //是否显示
      dialogFormVisible: false,
      //表单数据
      form: {
        //资源名称
        resources_name: "",
        //文件类型
        file_type: 1,
      },
      //左边标签宽度
      formLabelWidth: "120px",
    };
  },
  props: {
    visible: Boolean,
  },
  watch: {
    //监听是否显示
    visible(newVal, oldVal) {
      if (newVal != oldVal) {
        this.dialogFormVisible = newVal;
      }
    },
  },
  created() {},
  methods: {
    /**
     * 确认
     */
    confirmFunc() {
      this.$message({
        type: "success",
        message: "操作成功!",
      });
      this.cancelFunc();
    },

    /**
     * 取消
     */
    cancelFunc() {
      this.$emit("close", false);
    },
  },
};
</script>

<style lang="scss">
</style>